One, CSS length value
em
relative to the parent element's font size
ex
height relative to lowercase "x"
gd
Generally used in East Asian typography, this is not related to English
rem
relative to the root element font size
VW
relative to the view Window width: Window width is 100vw
vh
relative to the window heigh
Measurement, which is very important in web design. There are at least 10 different units of measurement in CSS.Each unit has its unique role, using them, can make the page, on various devices, very good work. Once you are familiar with all these units, you can more accurately set the size of the elements. In this tutorial, we'll look at the different units in CS
In CSS style sheets, we often see such units of length such as PT, Px,em,ex,in, and so on. What do they mean, what's the difference?In CSS style sheets, the length units are divided into two types:
Relative length units,
The length units in the CSS are currently divided into two types, absolute length and relative length respectively. Absolute length Units Include:
In: inch
Cm: cm
mm: mm
pt: lbs (1 lbs equals 1/72 inches)
When dealing with mobile pages, we sometimes need to make the banner diagram a wide square with the screen to get the best experience, such as the Flipbord mobile page: So how do you use pure CSS to make a square that can fit the size? Scenario One: CSS3 VW unit CSS3 has a new set of length units relative to the viewable area as a percentage of VW, VH, Vmin, Vmax. Where VW is a unit relative to the viewport
Original address: 1190000008934791?utm_source=tuicoolutm_medium=referralPX-pixelsPX is the most commonly used in CSS length units, can be used to specify the font size, the width of the element, height, border, padding, margin size and so on, it is a virtual length unit, is the digital image length unit of the computer
When writing CSS, the most commonly used length units are px (pixels), often see EM,PT and so on, in fact, the length of the CSS in a total of 8, respectively, is px,em,pt,ex,pc,in,mm,cm.
1, px: pixels (Pixel), relative to the device's length unit, pixels are relative to the display screen resolution.
For example, the
PrefaceThe unit of length can be divided into absolute length units and relative length units in general. CSS is the most well-known is the PX and EM, but at the same time there are PT, REM, VW, VH and other units of measurement,
1.pxThis is not much of an explanation, it is a physical pixel point on the screen. Eyes good small partner carefully look at the screen should be able to see the small lattice, not a drop of water to see.It is not recommended to use PX, the same picture may be different on different phone sizes. High resolution display of the small, low resolution of the large display.2.dpThis unit should be carefully understood, and it is related to pixel density. First say pixel density dpi, which is the numb
layout, point is an absolute value, which is equal to 1/72 inches, which can be measured by a ruler, in physical inches. But in CSS the meaning of PT is not so. Because our display is divided into pixels, a single pixel can only have one color (in order to simplify, the sub-pixel anti-aliasing technique is not discussed here), to display on the screen, you must first convert the length in PT to the length
Article 3. Pre-development knowledge supplement: length units and screen resolutions of Android, which are also reproduced ~~, Android screen resolutionThis article is a bit early, but it is very practical. For more information about the Unit, see the red part.
Screen Resolution Basics
1. terms and concepts
Terms
Description
Remarks
Screen size)
It refers to the actual physical si
First, introduce the DP and SP.DP is also dip. This is basically similar to SP. You can use a DP or SP if you set properties that represent length, height, and so on. However, if you set the font, you need to use the SP.The DP is not density-independent, and the SP is not related to scale, except for density. If the screen density is 160, then the DP and SP and PX are the same.1dp=1sp=1pxSecond, introduce the PXBut if you use PX as the unit, if the sc
There are many layout units in Android, such as: (DP, SP, PX, In, PT, and mm). But what is the difference between them? When should I use it again? I think even experienced developers sometimes cannot understand it.
DPI (DOT per inch): used to describe the screen density. For example, if the screen density is 160, there are 1 inch display points per 160.
In (inch): indicates the inch, which is the physical size of the screen. Equal to 2.54 per inch
C
After doing a small software, finally the margin and padding clear, now summarized as follows:The margin and padding of Android are the same as in HTML. As shown: The yellow part is padding and the gray part is margin.Popular understanding Padding is the inner border, margin is the outer boxThe corresponding properties are:12 3 456 78 android:paddingbottom= "1dip"If both the left and right settings are the same, you can set them directly:12 android:padding= "5dip"
Many netizens do not quite understand the difference between DP, SP, and PX: here we will introduce DP and sp. DP is dip. This is basically similar to sp. You can use DP or SP to specify attributes such as length and height. If you set the font, you need to use sp. DP is not related to density. SP is not only related to density, but also to scale. If the screen density is 160, DP and SP are the same as PX. 1dp = 1sp = 1px, but if PX is used as the uni
the screen density change. Next, let's take a look at the meaning of other units. Px: the actual pixel of the screen. For example, 320*480 screens have 320 pixels horizontally and 480 pixels vertically. In: indicates the inch, which is the physical size of the screen. Each inch equals 2.54 cm. For example, the screen size of a mobile phone is often described as 3.2 (English), 3.5 (English), and 4 (English. These dimensions are the diagonal
DPI: How many pixels are in an inch.PX: pixels, dots on the screen, this unit is not recommended.Dp:dp=dip (device independent pixels) devices independent pixels, easy to display the same effect on different resolution of the phone, generally set width and height. Conversion formula:SP: Depending on the size of the system font-size the user sets, the font size is generally set.Internal Spacing Settings properties: Layout_margin, Layout_margintop, and so on.Outer spacing Setting properties: Paddi
(including the border scrollbar, etc.), with a margin of 8px around the defaultIf the HTML is not set to color, the body color, the body color fills the entire backgroundViewport viewport refers to the viewable range of the browser, except the border, scroll bar, and the document display area of the toolbar.How can ②0.5em be equal to 1ex?The actual test found that the setting 0.5em and 1EX performance slightly different. After all, the lowercase x letter is half the font size font-size. Of cour
Today, we want to convert Px to mm, because the size of the pixel-to-other unit ratio varies with the resolution size set on the screen, so it cannot be calculated using a fixed number.Solution:Put a hidden block with a height of 1mm on the page Then use jquery to get its height var mmtopx =$ ("# divmmheight"). Height (); the height of mmtopx is the PX size corresponding to 1mm,The next step is to get the pixel height calculation of the object and get the le
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.